cmake_minimum_required(VERSION 3.10)

# Windows专用精臣条码打印机程序
project(BarcodePrinter VERSION 1.0.0 LANGUAGES CXX)

# 仅支持Windows
if(NOT WIN32)
    message(FATAL_ERROR "此项目仅支持Windows平台")
endif()

# C++11标准
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Windows编译选项
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /W3 /wd4996")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Od /Zi")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /O2")

# 预处理器定义
add_definitions(-D_CRT_SECURE_NO_WARNINGS -DWIN32_LEAN_AND_MEAN)

# 检查SDK文件
if(NOT EXISTS "${CMAKE_SOURCE_DIR}/bin/jcPrinterApi.dll")
    message(FATAL_ERROR "SDK DLL文件不存在: ${CMAKE_SOURCE_DIR}/bin/jcPrinterApi.dll")
endif()

# 创建可执行文件
add_executable(${PROJECT_NAME}
    main.cpp
    barcode_printer.cpp
    jcPrinter.cpp
)

# 链接库（动态加载DLL，不需要静态链接）
target_link_libraries(${PROJECT_NAME}
    user32
    gdi32
)